package com.vip.mvc.dispacher;

import com.vip.mvc.annotation.RequestMethod;
import com.vip.mvc.utils.JSONUtils;

import java.io.IOException;
import java.lang.reflect.Method;

/**
 * Created by cloudy.xie on 17/2/14.
 */
public class RequestParam {

    private String beanName;
    private String url;//除域名外的url ?之前域名之后
    private RequestMethod[] requestMethod;
    private Method method;
    private Object object;

    public RequestMethod[] getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(RequestMethod[] requestMethod) {
        this.requestMethod = requestMethod;
        if(this.requestMethod == null || this.requestMethod.length<=0){
            this.requestMethod = new RequestMethod[1];
            this.requestMethod[0] = RequestMethod.GET;
        }
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }

    public String getBeanName() {
        return beanName;
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    @Override
    public String toString() {
        try {
            return JSONUtils.toJSON(this);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
